package io.renren.modules.vastFinance.controller;

import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import io.renren.modules.vastFinance.entity.LoanlogEntity;
import io.renren.modules.vastFinance.service.LoanlogService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;


/**
 * 借款日志表
 *
 * @author syh
 * @email sunlightcs@gmail.com
 * @date 2022-05-19 09:40:52
 */
@RestController
@RequestMapping("crud/loanlog")
public class LoanlogController {
    @Autowired
    private LoanlogService loanlogService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("crud:loanlog:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = loanlogService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{loanId}")
    @RequiresPermissions("crud:loanlog:info")
    public R info(@PathVariable("loanId") Integer loanId){
		LoanlogEntity loanlog = loanlogService.getById(loanId);

        return R.ok().put("loanlog", loanlog);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("crud:loanlog:save")
    public R save(@RequestBody LoanlogEntity loanlog){
		loanlogService.save(loanlog);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("crud:loanlog:update")
    public R update(@RequestBody LoanlogEntity loanlog){
		loanlogService.updateById(loanlog);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("crud:loanlog:delete")
    public R delete(@RequestBody Integer[] loanIds){
		loanlogService.removeByIds(Arrays.asList(loanIds));

        return R.ok();
    }

}
